$(document).ready(function() {
     

  var  usuario = getCookie("usuario");
  var  senha = getCookie("senha");
   var status_login =0;
   status_login = getCookie("status_login");
   

validarCookie();
validarUsuario();
   

function validarUsuario(){
   // alert(status_login);
    if (status_login !== "1"){
       window.location.href = "/WakabaSoftbol/login.html";
        
    }
    
}


function validarCookie(){

    $.ajax({
        url: '/WakabaSoftbol/Controller_Login',
        type: 'POST',
        data: {
            oper: "7",
            usuario:usuario,
            senha: senha,
            status_login:status_login
          

        },
        complete: function(e, xhr, result) {
            if (e.readyState == 4 && e.status == 200) {
                try { //Converte a resposta HTTP JSON em um objeto JavaScript
                    var Obj = eval("(" + e.responseText + ")"); //Combo OS

                }
                catch (err) { //
                    // Mostra Aviso
 
                   // window.location.href = "/WakabaSoftbol/login.html";
                    
                }
                if (Obj != null) {
                    
                


                }
            }

        }
    });
    
    }


});



// JavaScript Document
// Código de domínio público escrito por Bill Dortch
function setCookie(name, value) 
{
   	var argv = setCookie.arguments;
   	var argc = setCookie.arguments.length;
   	var expires = (argc > 2) ? argv[2] : null;
   	var path = (argc > 3) ? argv[3] : null;
   	var domain= (argc > 4) ? argv[4] : null;
   	var secure= (argc>5) ? argv[5]: false;
   	document.cookie = name+"="+escape(value)+ 
  	((expires==null) ? "" : (";  expires= "+ expires.toGMTString())) +
  	((path == null) ? "": ("; path=" + path)) +  
  	((domain==null)? "": ("; domain=" + domain)) +
  	((secure==true)? "; secure": "");
}
function getCookie(name) 
{
   	var arg = name + "=";
   	var alen = arg.length;
   	var clen= document.cookie.length;
   	var i=0;
    	while (i < clen) {
      	var j = i + alen;
      	if (document.cookie.substring(i,j) == arg) 
           		return getCookieVal(j);
      	i = document.cookie.indexOf(" ", i) + 1;
    		if  (i == 0) break;
  	 }
   	return null;
}

function getCookieVal(offset) 
{
   	var endstr = document.cookie.indexOf(";", offset);
   	if (endstr == -1) endstr = document.cookie.length;
   	return unescape(document.cookie.substring(offset, endstr));
}


function delCookie(name) 
{
  	 if (getCookie(name)) {
       	document.cookie = name + "=" + "; expires = Thu, 01-Jan-70 00:00:01 GMT";
   	}
}